<template>
  <div>
    <el-page-header @back="goBack"> </el-page-header>
    <br />

    <el-table
      stripe
      style="font-size: 14px"
      :header-cell-style="{ background: '#eef1f6', color: '#606266' }"
      :data="stuData"
    >
      <el-table-column
        align="center"
        prop="stname"
        label="姓名"
        width="100"
        :show-overflow-tooltip="true"
      >
      </el-table-column>
      <el-table-column
        align="center"
        prop="stid"
        label="学号"
        width="150"
        :show-overflow-tooltip="true"
      >
      </el-table-column>
      <el-table-column
        align="center"
        prop="gender"
        label="性别"
        width="100"
        :show-overflow-tooltip="true"
      >
      </el-table-column>
      <el-table-column
        align="center"
        prop="age"
        label="年龄"
        width="100"
        :show-overflow-tooltip="true"
      >
      </el-table-column>
      <el-table-column
        align="center"
        prop="department"
        label="学校"
        width="150"
        :show-overflow-tooltip="true"
      >
      </el-table-column>
      <el-table-column
        align="center"
        prop="college"
        label="专业"
        width="200"
        :show-overflow-tooltip="true"
      >
      </el-table-column>
      <el-table-column
        align="center"
        prop="province"
        label="地址"
        width="180"
        :show-overflow-tooltip="true"
      >
      </el-table-column>
      <el-table-column
        align="center"
        prop="stype"
        label="学历"
        width="120"
        :show-overflow-tooltip="true"
      >
      </el-table-column>
      <el-table-column
        align="center"
        prop="year"
        label="入学年份"
        :show-overflow-tooltip="true"
      >
      </el-table-column>
    </el-table>
    <br />
    <br />
    <br />

    <el-container>
      <el-aside width="60%">
        <el-card>
          <div
            class="panel-body"
            id="scoreChart"
            style="height: 700px"
            ref="chart1"
          ></div>
        </el-card>
        <el-card>
          <div class="panel panel-default comment-panel">
            <div
              class="panel-body"
              id="treeCharts"
              style="height: 700px"
              ref="chart2"
            ></div>
          </div>
        </el-card>
      </el-aside>
      <el-main>
        <el-card>
          <div id="bar1">
            <!-- 为 ECharts 准备一个具备大小（宽高）的 DOM -->
            <div
              id="main1"
              style="float: left; width: 100%; height: 350px"
            ></div>
          </div>
        </el-card>
        <el-card>
          <div id="bar2">
            <!-- 为 ECharts 准备一个具备大小（宽高）的 DOM -->
            <div
              id="main2"
              style="float: left; width: 100%; height: 350px"
            ></div>
          </div>
        </el-card>
        <el-card>
          <div id="bar3">
            <!-- 为 ECharts 准备一个具备大小（宽高）的 DOM -->
            <div
              id="main3"
              style="float: left; width: 100%; height: 350px"
            ></div>
          </div>
        </el-card>
        <el-card>
          <div id="bar4">
            <!-- 为 ECharts 准备一个具备大小（宽高）的 DOM -->
            <div
              id="main4"
              style="float: left; width: 100%; height: 350px"
            ></div>
          </div>
        </el-card>
      </el-main>
    </el-container>
  </div>
</template>

<script>
export default {
  name: "stuInfoCheck",
  created () {
    this.initData()
  },
  data () {
    return {
      sizeMap: { 0: 10, 0.5: 15, 1: 20, 1.5: 25, 2: 30, 2.5: 35, 3: 40 },
      score: [0, 0, 0, 0, 0, 0, 0, 0],
      row: [],
      stuData: [],
      moodList: ["\u{1F604}", "\u{1F60A}", "\u{1F642}", "\u{1F610}", "\u{1F614}", "\u{1F641}", '☹️'],
      moods: [],
      infos: [],
      infoCode: ''
    }
  },
  watch: {
    row () {
      this.$nextTick(() => {
        //此时就可以获取到在created赋值后的dataList了
        this.createEcharts()

      })
    },
    moods () {
      this.$nextTick(() => {
        //此时就可以获取到在created赋值后的dataList了
        this.drawMood()

      })
    },
    infos () {
      this.$nextTick(() => {
        this.drawBodyInfo()
      })
    }
  },
  methods: {
    initData () {
      this.row = this.$route.query.info
      this.stuData.push(this.row)
      console.log(this.row.userId)
      this.$axios.post("managementSystem/student/stuInfo/getMood", { userId: this.row.userId })
        .then(data => {
          // console.log(data)
          if (data.status != 200) {
            this.$message.error('服务出错' + data.status)
          }
          else {
            console.log(data.data)
            this.moods = data.data.moods
          }
        }
        )
      this.$axios.post("managementSystem/student/stuInfo/getSevenDaysInfo", { userId: this.row.userId })
        .then(data => {
          // console.log(data)
          if (data.status != 200) {
            this.$message.error('服务出错' + data.status)
          }
          else {
            console.log(data.data)
            this.infoCode = data.data.errorCode
            this.infos = data.data.data
          }
        }
        )
      // this.moods = [{ "mood": "\uD83D\uDE04", "time": "1618541512833" }, { "mood": "\uD83D\uDE04", "time": "1618541512833" }, { "mood": "\uD83D\uDE04", "time": "1618541512833" }, { "mood": "\uD83D\uDE0A", "time": "1618542005024" }, { "mood": "\uD83D\uDE42", "time": "1618890041818" }, { "mood": "\uD83D\uDE10", "time": "1618890041818" }, { "mood": "\uD83D\uDE04", "time": "1618890041818" }]
    },
    isDepressedAnd (d) {
      var flag = true
      for (var i = 0; i < d.length; i++) {
        if (d[i] < 2) {
          flag = false
        }
      }
      return flag
    },
    isDepressdOr (d) {
      var flag = false
      for (var i = 0; i < d.length; i++) {
        if (d[i] >= 2) {
          flag = true
        }
      }
      return flag
    },
    createEcharts () {
      //坑点！！！要先设置dialogFormVisible为true才行，否则一直找不到对应的echarts元素，也就是找不到this.$refs.chart1
      //================================每项指标得分================================//
      var scoreCharts = this.$echarts.init(this.$refs.chart1)
      console.log(scoreCharts)
      var myColor = ['#eb2100', '#eb3600', '#d0570e', '#d0a00e', '#34da62', '#00e9db', '#00c0e9', '#0096f3', '#33CCFF', '#33FFCC']
      var scoreOption = {
        title: {
          text: '每项指标得分',
          padding: [20, 20, 100, 100],
          x: 'center'
        },
        backgroundColor: 'white',
        grid: {
          left: '0%',
          top: '3%',
          right: '5%',
          bottom: '8%',
          containLabel: true,

        },
        xAxis: [{
          show: false,
        }],
        yAxis: [{
          axisTick: 'none',
          axisLine: 'none',
          offset: '0',
          axisLabel: {
            textStyle: {
              color: 'black',
              fontSize: '20',
            }
          },
          data: ['自杀倾向', '自残倾向', '抑郁/不开心', '兴趣缺失', '时而狂躁', '异常表现', '睡眠障碍', '注意力不集中']
        }, {
          axisTick: 'none',
          axisLine: 'none',
          axisLabel: {
            textStyle: {
              color: '#000000',
              fontSize: '20',
            }
          },
          data: this.score
        }, {
          name: '分拨延误TOP 10',
          nameGap: '50',
          nameTextStyle: {
            color: '#ffffff',
            fontSize: '16',
          },
          axisLine: {
            lineStyle: {
              color: 'rgba(0,0,0,0)'
            }
          },
          data: [],
        }],
        series: [{
          name: '条',
          type: 'bar',
          yAxisIndex: 0,
          data: this.score,
          label: {
            normal: {
              show: false,
              position: 'center',
              textStyle: {
                color: '#ffffff',
                fontSize: '16',
              }
            }
          },
          barWidth: 5,//影响了整个图的宽度
          itemStyle: {
            normal: {
              color: function (params) {
                var num = myColor.length
                return myColor[params.dataIndex % num]
              },
            }
          },
          z: 2
        }, {
          name: '白框',
          type: 'bar',
          yAxisIndex: 1,
          barGap: '-100%',
          // data:[4, 4, 4, 4, 4, 4, 4, 4],
          data: [3, 3, 3, 3, 3, 3, 3, 3],
          barWidth: 5,
          itemStyle: {
            normal: {
              color: '#0e2147',
              barBorderRadius: 3,
            }
          },
          z: 1
        }, {
          name: '外框',
          type: 'bar',
          yAxisIndex: 2,
          barGap: '-100%',
          // data: [4, 4, 4, 4, 4, 4, 4, 4],
          data: [3, 3, 3, 3, 3, 3, 3, 3],
          barWidth: 5,
          itemStyle: {
            normal: {
              color: function (params) {
                var num = myColor.length
                return myColor[params.dataIndex % num]
              },
              barBorderRadius: 3,
            }
          },
          z: 0
        },

        ]
      }
      //scoreCharts.setOption(scoreOption);
      //================================每项指标得分================================//
      //================================树状图================================//
      var treeCharts = this.$echarts.init(this.$refs.chart2)
      var treeOption = {
        backgroundColor: new this.$echarts.graphic.RadialGradient(1, 1, 1, [{
          offset: 0,
          color: 'white'
        }, {
          offset: 1,
          color: 'white'
        }]),
        title: {
          text: "抑郁症状树图",
          subtext: "",
          x: 'center'

        },
        tooltip: {},
        legend: [{
          // formatter: function(name) {
          //     return this.$echarts.format.truncateText(name,150, '14px Microsoft Yahei', '…');
          // },
          tooltip: {
            show: true
          },
          x: 'center',
          selectedMode: 'false',
          bottom: 50,
          data: ['核心症状', '主要症状', '其他症状']
        }],
        animationDuration: 3000,
        animationEasingUpdate: 'quinticInOut',
        series: [{
          name: '抑郁症状',
          type: 'graph',
          layout: 'force',

          force: {
            repulsion: 800
          },
          data: [
            {
              "name": "抑郁症状",
              // "x": 0,
              // y: 0,
              "symbolSize": 80,
              "draggable": "true",
              "value": 8

            }, {
              "name": "核心症状",
              "value": 5,
              "symbolSize": 50,
              "category": "核心症状",
              "draggable": "true"

            }, {
              "name": "主要症状",
              "value": 5,
              "symbolSize": 50,
              "category": "主要症状",
              "draggable": "true"

            }, {
              "name": "其他症状",
              "value": 5,
              "symbolSize": 50,
              "category": "其他症状",
              "draggable": "true"

            },
            // {
            // 	"name": "抑郁/不开心",
            // 	"symbolSize": 30,
            // 	"category": "核心症状",
            // 	"draggable": "true",
            // 	"value": 1
            // }, {
            // 	"name": "兴趣缺失",
            // 	"symbolSize": 30,
            // 	"category": "核心症状",
            // 	"draggable": "true",
            // 	"value": 1
            // }, {
            // 	"name": "注意力不集中",
            // 	"symbolSize": 30,
            // 	"category": "主要症状",
            // 	"draggable": "true",
            // 	"value": 1
            // }, {
            // 	"name": "异常表现",
            // 	"symbolSize": 30,
            // 	"category": "主要症状",
            // 	"draggable": "true",
            // 	"value": 1
            // }, {
            // 	"name": "自残倾向",
            // 	"symbolSize": 30,
            // 	"category": "主要症状",
            // 	"draggable": "true",
            // 	"value": 1
            // }, {
            // 	"name": "自杀倾向",
            // 	"symbolSize": 30,
            // 	"category": "主要症状",
            // 	"draggable": "true",
            // 	"value": 1
            // }, {
            // 	"name": "睡眠障碍",
            // 	"symbolSize": 30,
            // 	"category": "主要症状",
            // 	"draggable": "true",
            // 	"value": 1
            // },  {
            // 	"name": "时而狂躁",
            // 	"symbolSize": 30,
            // 	"category": "其他症状",
            // 	"draggable": "true",
            // 	"value": 1
            // }
          ],
          links: [{
            "source": "抑郁症状",
            "target": "主要症状"
          }, {
            "source": "抑郁症状",
            "target": "核心症状"
          }, {
            "source": "抑郁症状",
            "target": "其他症状"
          },
            // 	{
            // 	"source": "核心症状",
            // 	"target": "抑郁/不开心"
            // }, {
            // 	"source": "核心症状",
            // 	"target": "兴趣缺失"
            // }, {
            // 	"source": "主要症状",
            // 	"target": "注意力不集中"
            // }, {
            // 	"source": "主要症状",
            // 	"target": "异常表现"
            // }, {
            // 	"source": "主要症状",
            // 	"target": "自残倾向"
            // }, {
            // 	"source": "主要症状",
            // 	"target": "自杀倾向"
            // }, {
            // 	"source": "主要症状",
            // 	"target": "睡眠障碍"
            // }, {
            // 	"source": "其他症状",
            // 	"target": "时而狂躁"
            // }
          ],
          categories: [{
            'name': '主要症状'
          }, {
            'name': '核心症状'
          }, {
            'name': '其他症状'
          }],
          focusNodeAdjacency: true,
          roam: true,
          label: {
            normal: {

              show: true,
              position: 'top',

            }
          },
          lineStyle: {
            normal: {
              color: 'source',
              curveness: 0,
              type: "solid"
            }
          }
        }]
      }
      //treeCharts.setOption(treeOption);
      //================================树状图图================================//
      var scoreString = this.row.symptoms
      console.log(scoreString)
      if (scoreString != null && scoreString != "") {
        var scores = []
        for (var i = 0; i < scoreString.length; i++)
          scores.push(parseInt(scoreString[i]))
        //每项指标
        this.score[0] = scores[11]
        this.score[1] = (scores[9] + scores[10]) / 2
        this.score[2] = scores[0]
        this.score[3] = (scores[2] + scores[3]) / 2
        this.score[4] = scores[17]
        this.score[5] = (scores[7] + scores[16]) / 2
        this.score[6] = (scores[13] + scores[14]) / 2
        this.score[7] = scores[4]
        scoreCharts.setOption(scoreOption)
        //树状图
        var dataNewStatus = [
          {
            "name": "抑郁症状",
            // "x": 0,
            // y: 0,
            "symbolSize": 80,
            "draggable": "true",
            "value": 8

          },
          {
            "name": "核心症状",
            "value": 5,
            "symbolSize": 50,
            "category": "核心症状",
            "draggable": "true"

          },
          {
            "name": "主要症状",
            "value": 5,
            "symbolSize": 50,
            "category": "主要症状",
            "draggable": "true"

          },
          {
            "name": "其他症状",
            "value": 5,
            "symbolSize": 50,
            "category": "其他症状",
            "draggable": "true"
          }
        ]
        var linkNew = [
          {
            "source": "抑郁症状",
            "target": "主要症状"
          },
          {
            "source": "抑郁症状",
            "target": "核心症状"
          },
          {
            "source": "抑郁症状",
            "target": "其他症状"
          }
        ]
        //-------------------核心症状----------------------start//
        if (this.isDepressedAnd([scores[0], scores[1]]) || this.score[2] > 0) {
          dataNewStatus.push({
            "name": "抑郁/不开心",
            "symbolSize": this.sizeMap[this.score[2]],
            "category": "核心症状",
            "draggable": "true",
            "value": this.score[2]
          })
          linkNew.push({
            "source": "核心症状",
            "target": "抑郁/不开心",
            // lineStyle:{
            //     normal:{
            //         type:'dotted'
            //     }
            // }
          })
        } else {
          dataNewStatus.push({
            "name": "抑郁/不开心",
            "symbolSize": 10,
            "category": "核心症状",
            "draggable": "true",
          })
          linkNew.push({
            "source": "核心症状",
            "target": "抑郁/不开心",
            lineStyle: {
              normal: {
                type: 'dotted'
              }
            }
          })
        }
        if (this.isDepressdOr([scores[2], scores[3]]) || this.score[3] > 0) {
          dataNewStatus.push({
            "name": "兴趣缺失",
            "symbolSize": this.sizeMap[this.score[3]],
            "category": "核心症状",
            "draggable": "true",
            "value": this.score[3]
          })
          linkNew.push({
            "source": "核心症状",
            "target": "兴趣缺失",
          })
        } else {
          dataNewStatus.push({
            "name": "兴趣缺失",
            "symbolSize": 10,
            "category": "核心症状",
            "draggable": "true",
          })
          linkNew.push({
            "source": "核心症状",
            "target": "兴趣缺失",
            lineStyle: {
              normal: {
                type: 'dotted'
              }
            }
          })
        }
        if (this.isDepressedAnd([scores[4]]) || this.score[7] > 0) {
          dataNewStatus.push({
            "name": "注意力不集中",
            "symbolSize": this.sizeMap[this.score[7]],
            "category": "核心症状",
            "draggable": "true",
            "value": this.score[7]
          })
          linkNew.push({
            "source": "核心症状",
            "target": "注意力不集中"
          })
        } else {
          dataNewStatus.push({
            "name": "注意力不集中",
            "symbolSize": 10,
            "category": "核心症状",
            "draggable": "true",
          })
          linkNew.push({
            "source": "核心症状",
            "target": "注意力不集中",
            lineStyle: {
              normal: {
                type: 'dotted'
              }
            }
          })
        }
        //-------------------核心症状----------------------end//
        //-------------------主要症状----------------------start//
        if (this.isDepressdOr([scores[5], scores[6]])) {
          dataNewStatus.push({
            "name": "选择困难",
            "symbolSize": 30,
            "category": "主要症状",
            "draggable": "true",
            "value": 1
          })
          linkNew.push({
            "source": "主要症状",
            "target": "选择困难"
          })
        } else {
          dataNewStatus.push({
            "name": "选择困难",
            "symbolSize": 10,
            "category": "主要症状",
            "draggable": "true",
          })
          linkNew.push({
            "source": "主要症状",
            "target": "选择困难",
            lineStyle: {
              normal: {
                type: 'dotted'
              }
            }
          })
        }
        if (this.isDepressedAnd([scores[7]]) || this.score[5] > 0) {
          dataNewStatus.push({
            "name": "异常表现",
            "symbolSize": this.sizeMap[this.score[5]],
            "category": "主要症状",
            "draggable": "true",
            "value": this.score[5]
          })
          linkNew.push({
            "source": "主要症状",
            "target": "异常表现"
          })
        } else {
          dataNewStatus.push({
            "name": "异常表现",
            "symbolSize": 10,
            "category": "主要症状",
            "draggable": "true",
          })
          linkNew.push({
            "source": "主要症状",
            "target": "异常表现",
            lineStyle: {
              normal: {
                type: 'dotted'
              }
            }
          })
        }
        if (this.isDepressedAnd([scores[8]])) {
          dataNewStatus.push({
            "name": "无价值感",
            "symbolSize": 30,
            "category": "主要症状",
            "draggable": "true",
            "value": 1
          })
          linkNew.push({
            "source": "主要症状",
            "target": "无价值感"
          })
        } else {
          dataNewStatus.push({
            "name": "无价值感",
            "symbolSize": 10,
            "category": "主要症状",
            "draggable": "true",
          })
          linkNew.push({
            "source": "主要症状",
            "target": "无价值感",
            lineStyle: {
              normal: {
                type: 'dotted'
              }
            }
          })
        }
        if (this.isDepressedAnd([scores[9]]) || this.score[1] > 0) {
          dataNewStatus.push({
            "name": "自残倾向",
            "symbolSize": this.sizeMap[this.score[1]],
            "category": "主要症状",
            "draggable": "true",
            "value": this.score[1]
          })
          linkNew.push({
            "source": "主要症状",
            "target": "自残倾向"
          })
        } else {
          dataNewStatus.push({
            "name": "自残倾向",
            "symbolSize": 10,
            "category": "主要症状",
            "draggable": "true",
          })
          linkNew.push({
            "source": "主要症状",
            "target": "自残倾向",
            lineStyle: {
              normal: {
                type: 'dotted'
              }
            }
          })
        }
        if (this.isDepressedAnd([scores[10]]) || this.score[0] > 0) {
          dataNewStatus.push({
            "name": "自杀倾向",
            "symbolSize": this.sizeMap[this.score[0]],
            "category": "主要症状",
            "draggable": "true",
            "value": this.score[0]
          })
          linkNew.push({
            "source": "主要症状",
            "target": "自杀倾向"
          })
        } else {
          dataNewStatus.push({
            "name": "自杀倾向",
            "symbolSize": 10,
            "category": "主要症状",
            "draggable": "true",
          })
          linkNew.push({
            "source": "主要症状",
            "target": "自杀倾向",
            lineStyle: {
              normal: {
                type: 'dotted'
              }
            }
          })
        }
        if (this.isDepressedAnd([scores[11]])) {
          dataNewStatus.push({
            "name": "自杀计划",
            "symbolSize": 30,
            "category": "主要症状",
            "draggable": "true",
            "value": 1
          })
          linkNew.push({
            "source": "主要症状",
            "target": "自杀计划"
          })
        } else {
          dataNewStatus.push({
            "name": "自杀计划",
            "symbolSize": 10,
            "category": "主要症状",
            "draggable": "true",
          })
          linkNew.push({
            "source": "主要症状",
            "target": "自杀计划",
            lineStyle: {
              normal: {
                type: 'dotted'
              }
            }
          })
        }
        if (this.isDepressdOr([scores[12], scores[13], scores[14]]) || this.score[6] > 0) {
          dataNewStatus.push({
            "name": "睡眠障碍",
            "symbolSize": this.sizeMap[this.score[6]],
            "category": "主要症状",
            "draggable": "true",
            "value": this.score[6]
          })
          linkNew.push({
            "source": "主要症状",
            "target": "睡眠障碍"
          })
        } else {
          dataNewStatus.push({
            "name": "睡眠障碍",
            "symbolSize": 10,
            "category": "主要症状",
            "draggable": "true",
          })
          linkNew.push({
            "source": "主要症状",
            "target": "睡眠障碍",
            lineStyle: {
              normal: {
                type: 'dotted'
              }
            }
          })
        }
        if (this.isDepressedAnd([scores[15]])) {
          dataNewStatus.push({
            "name": "食欲异常",
            "symbolSize": 30,
            "category": "主要症状",
            "draggable": "true",
            "value": 1
          })
          linkNew.push({
            "source": "主要症状",
            "target": "食欲异常"
          })
        } else {
          dataNewStatus.push({
            "name": "食欲异常",
            "symbolSize": 10,
            "category": "主要症状",
            "draggable": "true",
          })
          linkNew.push({
            "source": "主要症状",
            "target": "食欲异常",
            lineStyle: {
              normal: {
                type: 'dotted'
              }
            }
          })
        }
        if (this.isDepressedAnd([scores[16]])) {
          dataNewStatus.push({
            "name": "动作缓慢、容易烦躁",
            "symbolSize": 30,
            "category": "主要症状",
            "draggable": "true",
            "value": 1
          })
          linkNew.push({
            "source": "主要症状",
            "target": "动作缓慢、容易烦躁"
          })
        } else {
          dataNewStatus.push({
            "name": "动作缓慢、容易烦躁",
            "symbolSize": 10,
            "category": "主要症状",
            "draggable": "true",
          })
          linkNew.push({
            "source": "主要症状",
            "target": "动作缓慢、容易烦躁",
            lineStyle: {
              normal: {
                type: 'dotted'
              }
            }
          })
        }
        //-------------------主要症状----------------------end//
        //-------------------其他症状----------------------start//
        if (this.isDepressedAnd([scores[17]]) || this.score[4] > 0) {
          dataNewStatus.push({
            "name": "时而狂躁",
            "symbolSize": this.sizeMap[this.score[4]],
            "category": "其他症状",
            "draggable": "true",
            "value": this.score[4]
          })
          linkNew.push({
            "source": "其他症状",
            "target": "时而狂躁"
          })
        } else {
          dataNewStatus.push({
            "name": "时而狂躁",
            "symbolSize": 10,
            "category": "其他症状",
            "draggable": "true",
          })
          linkNew.push({
            "source": "其他症状",
            "target": "时而狂躁",
            lineStyle: {
              normal: {
                type: 'dotted'
              }
            }
          })
        }
        if (this.isDepressedAnd([scores[18]])) {
          dataNewStatus.push({
            "name": "社会关系、不安全感",
            "symbolSize": 30,
            "category": "其他症状",
            "draggable": "true",
            "value": 1
          })
          linkNew.push({
            "source": "其他症状",
            "target": "社会关系、不安全感"
          })
        } else {
          dataNewStatus.push({
            "name": "社会关系、不安全感",
            "symbolSize": 10,
            "category": "其他症状",
            "draggable": "true",
          })
          linkNew.push({
            "source": "其他症状",
            "target": "社会关系、不安全感",
            lineStyle: {
              normal: {
                type: 'dotted'
              }
            }
          })
        }
        if (this.isDepressedAnd([scores[19]])) {
          dataNewStatus.push({
            "name": "焦虑、抑郁",
            "symbolSize": 30,
            "category": "其他症状",
            "draggable": "true",
            "value": 1
          })
          linkNew.push({
            "source": "其他症状",
            "target": "焦虑、抑郁"
          })
        } else {
          dataNewStatus.push({
            "name": "焦虑、抑郁",
            "symbolSize": 10,
            "category": "其他症状",
            "draggable": "true",
          })
          linkNew.push({
            "source": "其他症状",
            "target": "焦虑、抑郁",
            lineStyle: {
              normal: {
                type: 'dotted'
              }
            }
          })
        }
        //-------------------其他症状----------------------end//
        treeOption.series[0].data = dataNewStatus
        treeOption.series[0].links = linkNew
        treeCharts.setOption(treeOption)
        treeCharts.resize()
      } else {
        console.log('评测结果为空')
      }
    },
    drawMood () {
      var that = this
      var xdata = this.moods.map(t => {
        let timestamp = new Date(Number(t.time))
        var month = (timestamp.getMonth() + 1)
        month = month < 10 ? '0' + month : month
        var day = timestamp.getDate()
        day = day < 10 ? '0' + day : day
        return month + '/' + day
      })
      var ydata = this.moods.map(t => {
        let mood = t.mood
        if (mood == this.moodList[0]) {
          return 6
        } else if (mood == this.moodList[1]) {
          return 5
        } else if (mood == this.moodList[2]) {
          return 4
        } else if (mood == this.moodList[3]) {
          return 3
        } else if (mood == this.moodList[4]) {
          return 2
        } else if (mood == this.moodList[5]) {
          return 1
        } else {
          return 0
        }
      })
      console.log(ydata)
      let myChartDrawer = this.$echarts.init(document.getElementById('main1'))
      var option = {
        title: {
          text: '心情曲线',
          x: 'center',//x轴方向对齐方式
        },
        dataLabel: false,
        dataPointShape: true,
        series: [{
          type: 'line',
          name: '心情曲线',
          data: ydata,
        }],
        xAxis: {
          disableGrid: false,
          data: xdata
        },
        yAxis: {
          name: '心情',
          nameLocation: 'center',
          nameTextStyle: {
            fontSize: 14,
            padding: [0, 0, 15, 0]    // 四个数字分别为上右下左与原位置距离
          },
          axisLabel: {
            formatter: function (val) {
              return that.moodList[6 - Number(val)]
            }
          },
          min: 0,
          max: 6
        },
        // width: 340,
        // height: 200,
        legend: false,
        extra: {
          lineStyle: 'curve'
        }
      }
      myChartDrawer.setOption(option)
    },
    drawBodyInfo () {
      let width = 340
      let height = 200
      var pains = []
      var sleeps = []
      var appetites = []
      var weights = []
      var time = []
      if (this.infoCode == 200) {
        var infos = this.infos.map(v => {
          let score = '0'
          let sleep = v.sleep
          let arr = sleep.split(',')
          if (arr.length == 1 && sleep.indexOf("正常") != -1) {
            score = '0'
          } else {
            if (sleep.indexOf("正常") != -1) {
              score = arr.length - 1
            } else {
              score = arr.length
            }
          }
          v.sleep = score
          v.time = v.time.substring(5)
          return v
        })

        for (var i = 0; i < infos.length; i++) {
          pains.push(infos[i].pain)
          sleeps.push(infos[i].sleep)
          appetites.push(infos[i].appetite)
          weights.push(infos[i].weight)
          time.push(infos[i].time)
        }
      }
      let myChartDrawer = this.$echarts.init(document.getElementById('main2'))
      var option = {
        title: {
          text: '睡眠-疼痛曲线',
          x: 'center',//x轴方向对齐方式
        },
        dataLabel: false,
        dataPointShape: true,
        series: [
          {
            type: 'line',
            name: '疼痛',
            data: pains,
          }, {
            type: 'line',
            name: '睡眠',
            data: sleeps,
          }],
        xAxis: {
          disableGrid: false,
          data: time
        },
        yAxis: {
          name: '分数越高，越严重',
          nameLocation: 'center',
          nameTextStyle: {
            fontSize: 14,
            padding: [0, 0, 10, 0]    // 四个数字分别为上右下左与原位置距离
          },
          format: function (val) {
            return val
          },
          min: 0,
          max: 6
        },
        // width: width,
        // height: height,
        legend: false,
        extra: {
          lineStyle: 'curve'
        }
      }
      myChartDrawer.setOption(option)
      let myChartDrawer3 = this.$echarts.init(document.getElementById('main3'))
      var option3 = {
        title: {
          text: '食欲曲线',
          x: 'center',//x轴方向对齐方式
        },
        dataLabel: false,
        dataPointShape: true,
        series: [{
          type: 'line',
          name: '食欲',
          data: appetites,
        }],
        xAxis: {
          disableGrid: false,
          data: time
        },
        yAxis: {
          name: '正分好，负分差',
          nameLocation: 'center',
          nameTextStyle: {
            fontSize: 14,
            padding: [0, 0, 10, 0]    // 四个数字分别为上右下左与原位置距离
          },
          format: function (val) {
            return val
          },
          min: 0,
          max: 6
        },
        // width: width,
        // height: height,
        legend: false,
        extra: {
          lineStyle: 'curve'
        }
      }
      myChartDrawer3.setOption(option3)
      let myChartDrawer4 = this.$echarts.init(document.getElementById('main4'))
      var option4 = {
        title: {
          text: '体重曲线',
          x: 'center',//x轴方向对齐方式
        },
        dataLabel: true,
        dataPointShape: true,
        series: [{
          type: 'line',
          name: '体重',
          data: weights
        }],
        xAxis: {
          disableGrid: false,
          data: time
        },
        yAxis: {
          name: '单位（kg）',
          nameLocation: 'center',
          nameTextStyle: {
            fontSize: 14,
            padding: [0, 0, 10, 0]    // 四个数字分别为上右下左与原位置距离
          },
          format: function (val) {
            return val
          },
        },
        // width: width,
        // height: height,
        legend: false,
        extra: {
          lineStyle: 'curve'
        }
      }
      myChartDrawer4.setOption(option4)
    },
    goBack () {
      this.$router.go(-1)
    }
  }
}
</script>

<style scoped>
</style>
